package cn.kgm.makeGodV2.outCome;

import cn.kgm.makeGodV2.GamePlayer;
import cn.kgm.makeGodV2.WorldState;
import cn.kgm.makeGodV2.personalityTag.PersonalityTag;
import cn.kgm.makeGodV2.personalityTag.PersonalityTagManager;

import java.util.Optional;

/**
 * @Version 1.8
 * @Author: Kappi
 * @Date: 2025-9-16 10:35
 * @Description: cn.kgm.makeGodV2.outCome.TagAddOutcome
 */
public class TagAddOutcome implements EventOutcome {

    private PersonalityTag tag;

    public TagAddOutcome(PersonalityTag tag) {
        this.tag = tag;
    }

    @Override
    public void apply(GamePlayer npc, WorldState worldState) {
        PersonalityTagManager tagManager = Optional.ofNullable(npc).map(GamePlayer::getPersonalityTagManager)
                .orElse(PersonalityTagManager.builder().build());
        tagManager.addTag(tag);
        npc.setPersonalityTagManager(tagManager);
    }
}
